package enumdemo;

import reflectdemo.Test;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: MENG
 * Date: 2022-08-14
 * Time: 16:47
 */
public enum TestEnum {
    RED,BLACK("balck",2),GREEN,WHITE;

    public String color;
    public int ordinal;

    TestEnum(String color, int ordinal) {
        this.color = color;
        this.ordinal = ordinal;
    }
    TestEnum() {
    }


    public static void main2(String[] args) {
        TestEnum testEnum = TestEnum.GREEN;
        TestEnum testEnum1 = TestEnum.RED;
        System.out.println(testEnum.compareTo(testEnum1));
        System.out.println(BLACK.compareTo(RED));
        System.out.println(RED.compareTo(BLACK));
    }

    public static void main1(String[] args) {
/*        TestEnum[] testEnums = TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i] +" 序号" + testEnums[i].ordinal());
        }*/

        TestEnum testEnum =TestEnum.valueOf("GREEN");
        System.out.println(testEnum);
    }

    public static void main(String[] args) {
        TestEnum testEnum2 = TestEnum.BLACK;
        switch (testEnum2) {
            case RED:
                System.out.println("red");
                break;
            case BLACK:
                System.out.println("black");
                break;
            case WHITE:
                System.out.println("WHITE");
                break;
            case GREEN:
                System.out.println("green");
                break;
            default:
                break;
        }
    }
}
